package com.roshan.web.util;

import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.util.StringUtils;

@SuppressWarnings("nls")
public class RoarStringUtils {

    public static Map<String, String> stringToMap(String input) {

        if (!StringUtils.hasText(input)) {
            return null;
        }
        Map<String, String> map = new LinkedHashMap<String, String>();
        int length = input.length();
        String formattedInput = input.substring(1, length - 1);

        String[] nameValuePairs = formattedInput.split(",");
        for (String nameValuePair : nameValuePairs) {
            String[] nameValue = nameValuePair.split("=");
            map.put(nameValue[0].trim(), nameValue[1]);
        }
        return map;
    }

}
